package com.dongdongshop.Service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.data.Page;
import com.dongdongshop.log.DKLog;
import com.dongdongshop.mapper.TbTypeTemplateMapper;
import com.dongdongshop.pojo.TbSpecification;
import com.dongdongshop.pojo.TbTypeTemplate;
import com.dongdongshop.service.TypeTemplateService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
@org.springframework.stereotype.Service
public class TypeTemplateServiceImpl implements TypeTemplateService {

    @Autowired
    private TbTypeTemplateMapper tbTypeTemplateMapper;

    //查询
    @Override
    public Page<TbTypeTemplate> templatePage(String name,Integer pageNumber, Integer pageSize) {
        PageHelper.startPage(pageNumber,pageSize);
        List<TbTypeTemplate> list = tbTypeTemplateMapper.templatePage(name);
        PageInfo<TbTypeTemplate> info = new PageInfo<>(list);
        return new Page<TbTypeTemplate>(info.getPageNum(),info.getPageSize(),info.getTotal(),info.getPages(),info.getList());
    }

    @Override
    public Integer addInfo(TbTypeTemplate tbTypeTemplate) {
        return tbTypeTemplateMapper.insert(tbTypeTemplate);
    }

    @Override
    public TbTypeTemplate getTypeById(Long id) {
        return tbTypeTemplateMapper.selectByPrimaryKey(id);
    }

    @Override
    public Integer updateInfo(TbTypeTemplate tbTypeTemplate) {
        return tbTypeTemplateMapper.updateByPrimaryKey(tbTypeTemplate);
    }

    @Override
    public Integer deleteTypeById(Long[] id) {
        return tbTypeTemplateMapper.deleteTypeById(id);
    }

    @Override
    public Integer deleteById(Long id) {
        return tbTypeTemplateMapper.deleteByPrimaryKey(id);
    }
}
